/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aprendizajePorRefuerzo.interfaz;

import aprendizajePorRefuerzo.agente.AgenteSarsa;

/**
 *
 * @author Fernando Sorzana
 */
public class PnlParametrosSarsa extends PnlParametrosAgente {

    /**
     * Creates new form PnlParametrosSarsa
     */
    public PnlParametrosSarsa() {
        initComponents();
    }
    
    public void actualizarParametros(){
        if (txtAlfa.getValue() != null){
            ((AgenteSarsa)getAgente()).setAlfa((double)txtAlfa.getValue());
        }
        if (txtGamma.getValue() != null){
            ((AgenteSarsa)getAgente()).setGamma((double)txtGamma.getValue());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtAlfa = new javax.swing.JFormattedTextField();
        txtGamma = new javax.swing.JFormattedTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        txtAlfa.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        txtAlfa.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtAlfaFocusLost(evt);
            }
        });

        txtGamma.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        txtGamma.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtGammaFocusLost(evt);
            }
        });

        jLabel1.setText("γ:");

        jLabel2.setText("α:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtGamma, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtAlfa)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtGamma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtAlfa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void txtAlfaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAlfaFocusLost
        if (txtAlfa.getValue() != null){
            ((AgenteSarsa)getAgente()).setAlfa((double)txtAlfa.getValue());
        }
    }//GEN-LAST:event_txtAlfaFocusLost

    private void txtGammaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtGammaFocusLost
        if (txtGamma.getValue() != null){
            ((AgenteSarsa)getAgente()).setGamma((double)txtGamma.getValue());
        }
    }//GEN-LAST:event_txtGammaFocusLost

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JFormattedTextField txtAlfa;
    private javax.swing.JFormattedTextField txtGamma;
    // End of variables declaration//GEN-END:variables
}
